package org.fintan.make.configs;

import org.fintan.make.master.TokenInterceptor;
import org.fintan.make.utils.JWTUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 加载拦截器
 * @author Fintan
 *
 * 2018年2月8日
 */
@Configuration
public class SessionConfiguration extends WebMvcConfigurerAdapter{

	private TokenInterceptor tokenInterceptor;
	private JWTUtil jwtUtil;
	
	@Autowired
	public SessionConfiguration(TokenInterceptor tokenInterceptor,JWTUtil jwtUtil) {
		this.jwtUtil = jwtUtil;
		this.tokenInterceptor = tokenInterceptor;
	}
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		 // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
		registry.addInterceptor(tokenInterceptor).addPathPatterns("/**").excludePathPatterns("/swagger*/**","/v2/**","/webjars/**","/hello");
	}


	
}
